package com.itheima.frwameworkcache.redis;

import lombok.extern.slf4j.Slf4j;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.data.redis.connection.RedisGeoCommands;
import org.springframework.data.redis.core.RedisCallback;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.test.context.junit4.SpringRunner;

import java.nio.charset.StandardCharsets;
import java.sql.Time;
import java.util.concurrent.TimeUnit;

/**
 * @author sunfeng
 * @date 2021/05/31 10:49
 **/
@Slf4j
@RunWith(SpringRunner.class)
@SpringBootTest
public class RedisAddKeys {
    @Autowired
    private RedisTemplate redisTemplate;

    @Test
    public void testAddRedisMessage() throws InterruptedException {
        redisTemplate.opsForValue().setBit("uid:sign:3000:202106", 2, true);
        System.out.println(redisTemplate.opsForValue().getBit("uid:sign:3000:202106", 2));

        System.out.println(redisTemplate.execute((RedisCallback<Long>) connection -> connection.bitCount("uid:sign:3000:202106".getBytes(StandardCharsets.UTF_8))));
    }
}
